package cn.faster.common.exception;

import cn.faster.common.result.ResultBean;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;


/**
 * description: GlobalExceptionResolver
 * date: 2021/6/17 14:36
 * author: XiaoCoder
 * version: 1.0
 */
@Slf4j
@ControllerAdvice
public class GlobalExceptionResolver {
    private static final Logger LOG = LoggerFactory.getLogger(GlobalExceptionResolver.class);

    @ExceptionHandler(RuntimeException.class)
    public ResultBean<String> runtimeExceptionHandler(Exception e) {
        log.error("\nexception-class -> {}" +
                        "\nexception-message -> {}",
                e.getClass(),
                e.getMessage());
        return ResultBean.ERROR();
    }
}
